import * as routerTypes from "@/constants/routerType";

/**
 * 获取归档id
 * @param classifyArray {array}
 * @param classify {string}
 * @returns {*}
 */
export function getClassifyId(classifyArray = [], classify) {
  if (classifyArray && classifyArray.length > 0) {
    for (const item of classifyArray) {
      if (item.classify === classify) {
        return item.id
      }
    }
  }
}

/**
 * 处理归档列表数据
 * @param classifyList {array}
 */
export function filterClassifyList(classifyList) {
  let tempArray = [];
  classifyList && classifyList.length > 0 && classifyList.forEach(item => {
    tempArray.push({
      text: item.classify,
      value: item.classify
    })
  })
  return tempArray;
}

export function typeToNav(type) {
  switch (type) {
    case routerTypes.HOME:
      return "工作台";
    case routerTypes.ADD_ARTICLE:
      return "添加文章";
    case routerTypes.ARTICLE_LIST:
      return "文章列表";
    case routerTypes.ARCHIVES:
      return "文章归档";
    case routerTypes.ADD_FRIEND:
      return "添加好友";
    case routerTypes.FRIEND_LIST:
      return "好友列表";
    case routerTypes.WALL:
      return "壁纸管理";
    case routerTypes.ADD_MUSIC:
      return "添加音乐";
    case routerTypes.MUSIC_LIST:
      return "音乐列表";
    case routerTypes.PROFILE:
      return "个人账号";
    default:
      return "404";
  }
}

